<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<script type="text/javascript" src="${ctx}/static/js/si.ajax.js"></script>
<!--可搜索下拉框-start-->
<link rel="stylesheet" href="${ctx}/static/ace/css/chosen.css" />
<link rel="stylesheet" href="${ctx}/static/ace/css/ace.min.css" />
<link rel="stylesheet" href="${ctx}/static/ace/css/ace-rtl.min.css" />
<link rel="stylesheet" href="${ctx}/static/ace/css/ace-skins.min.css" />
<script type="text/javascript"
	src="${ctx}/static/ace/js/chosen.jquery.min.js"></script>
<!--[if !IE]> -->

<script type="text/javascript">
			window.jQuery || document.write("<script src='${ctx}/static/ace/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
		</script>

<!-- <![endif]-->
<!--可搜索下拉框-end-->
<script type="text/javascript">
	var mappingId = '${mappingId}';
	var tableId = '${tableId}';
	
	function save(obj) {
		var isAll = $('#check_box').is(':checked');
		$('#content')[0].contentWindow.saveWhereEdit(obj, isAll);
	}
	
	function tableSqlTest(submitFlag){ 
		var sql = $("#where_edit_field").val();
		 $.ajax({
		   type: "POST",
		   url: _ctx + "/task/table_sql_test.do",
		   async: false,
		   cache: false,
		   data: {
			   dsMappingId: mappingId,
			   tableId: tableId,
			   testSql:sql
		   },
		   beforeSend: function(){
			  $("#testSqlBtn").val("正在验证...").attr("disabled","disabled");
	       },
		   success: function(data){
				if(data.status == 0){
					 alert(data.msg);
					 if(submitFlag){
						 sqlTestFlag = 0;
					 }
				  }else{
					  if(submitFlag){
						  sqlTestFlag= 1;
						}else{
							alert(data.msg);
						}
				  }
			  	$("#testSqlBtn").val("验证发布信息").attr("disabled",null);	
		   },
		   error:function(){
			   alert('系统异常,操作失败');
			   $("#testSqlBtn").val("验证发布信息").attr("disabled",null);
		   }
		}); 
	  }	
</script>
<div class="modal-header">
	<h4 class="modal-title">配置条件</h4>
</div>
<div class="modal-body overflow-visible">
	<div class="row">
		<div class="col-sm-12">
		
		<textarea class="form-control text_area" id="where_edit_field"
									value="${oldWhere}">${oldWhere}</textarea>
			<%-- <c:if test="${isShow}">
				<div id="ic_start_value_div">
					<table class='table table-striped table-bordered table-hover'>
						<thead>
							<tr>
								<th>增量字段:</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<td>${ic.colName}</td>
							</tr>
						</tbody>
					</table>
					<table class='table table-striped table-bordered table-hover'>
						<thead>
							<tr>
								<th>数据抽取起始值:</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<td><c:choose>
										<c:when test="${col.isIcDate}">
											<div id="end_date_pick">
												<!-- <input class="input-large" type="text" id="start_value" /> -->
												<span class="input-icon input-icon-right width-20"> <input
													type="text" class="form-control form-input" id="start_date"
													name="start_date" value="${oldEndValue}"
													onfocus="WdatePicker({onpicked:function(){},dateFmt:'yyyy-MM-dd'});" />
													<i class="icon-calendar blue pointer"
													onclick="javascript:$('#Date').focus();"></i>
												</span>
											</div>
										</c:when>
										<c:otherwise>
											<div id="start_text_input">
												<input class="input-large" type="text" id="start_text"
													value="${oldStartValue}" />
											</div>
										</c:otherwise>
									</c:choose></td>
							</tr>
						</tbody>
					</table>
					<c:if test="${executeType == '1'}">
						<table class='table table-striped table-bordered table-hover'>
							<thead>
								<tr>
									<th>数据抽取截止值:</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td><c:choose>
											<c:when test="${col.isIcDate}">
												<div id="end_date_pick">
													<!-- <input class="input-large" type="text" id="start_value" /> -->
													<span class="input-icon input-icon-right width-20">
														<input type="text" class="form-control form-input"
														id="end_date" name="end_date" value="${oldEndValue}"
														onfocus="WdatePicker({onpicked:function(){},dateFmt:'yyyy-MM-dd'});" />
														<i class="icon-calendar blue pointer"
														onclick="javascript:$('#Date').focus();"></i>
													</span>
												</div>
											</c:when>
											<c:otherwise>
												<div id="start_text_input">
													<input class="input-large" type="text" id="end_text"
														value="${oldEndValue}" />
												</div>
											</c:otherwise>
										</c:choose></td>
								</tr>
							</tbody>
						</table>
					</c:if>
				</div>
			</c:if> --%>

			<%-- <table class='table table-striped table-bordered table-hover'>
				<thead>
					<tr>
						<th>发布条件:</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td>
							<textarea class="form-control text_area" id="where_edit_field"
									value="${oldWhere}">${oldWhere}</textarea>
							<c:choose>
								<c:when test="${col.isIcDate}">
									<div id="end_date_pick">
										<!-- <input class="input-large" type="text" id="start_value" /> -->
										<span class="input-icon input-icon-right width-20"> <input
											type="text" class="form-control form-input" id="end_date"
											name="end_date" value="${oldEndValue}"
											onfocus="WdatePicker({onpicked:function(){},dateFmt:'yyyy-MM-dd'});" />
											<i class="icon-calendar blue pointer"
											onclick="javascript:$('#Date').focus();"></i>
										</span>
									</div>
								</c:when>
								<c:otherwise>
									<div id="start_text_input">
										<textarea class="form-control text_area" id="where_edit_field"
											value="${oldWhere}">${oldWhere}</textarea>
									</div>
								</c:otherwise>
							</c:choose>
						</td>
					</tr>
				</tbody>
			</table> --%>
			<%-- <div class="form-group">
							    <c:if test="${isShow}">
									<div id="ic_start_value_div">
									<div>
											<label>增量字段: </label> <label id="ic_name_label">${ic.colName}</label>
									</div>
									<br>
									
									<label for="start_value">数据抽取起始值: </label>
									<c:choose>
									<c:when test="${col.isIcDate}">
										<div id="start_date_pick">
										<!-- <input class="input-large" type="text" id="start_value" /> -->
										<span class="input-icon input-icon-right width-20"> <input
												type="text" class="form-control form-input" id="start_date"
												name="start_date" value="${oldStartValue}"
												onfocus="WdatePicker({onpicked:function(){},dateFmt:'yyyy-MM-dd'});" />
												<i class="icon-calendar blue pointer"
												onclick="javascript:$('#Date').focus();"></i> </span>
										</div>
									</c:when>
									<c:otherwise>
										<div id="start_text_input">
								    	<input class="input-large" type="text" id="start_text" value="${oldStartValue}"/>
								    </div>
									</c:otherwise>
									</c:choose>
													    
									<br>
									
									<c:if test="${executeType == '1'}">
										<label for="start_value">数据抽取截止值: </label>
										<c:choose>
										<c:when test="${col.isIcDate}">
											<div id="end_date_pick">
											<!-- <input class="input-large" type="text" id="start_value" /> -->
											<span class="input-icon input-icon-right width-20"> <input
													type="text" class="form-control form-input" id="end_date"
													name="end_date" value="${oldEndValue}"
													onfocus="WdatePicker({onpicked:function(){},dateFmt:'yyyy-MM-dd'});" />
													<i class="icon-calendar blue pointer"
													onclick="javascript:$('#Date').focus();"></i> </span>
											</div>
										</c:when>
										<c:otherwise>
											<div id="start_text_input">
									    	<input class="input-large" type="text" id="end_text" value="${oldEndValue}"/>
									    </div>
										</c:otherwise>
										</c:choose>
										
										<br>
									</c:if>
									
									</div>
								</c:if>
								
								<label for="where_edit_field">发布条件: </label>
								<textarea class="form-control text_area" id="where_edit_field" value="${oldWhere}">${oldWhere}</textarea>
								
								
							</div> --%>
		</div>
		
		<div class="col-sm-12" style="margin-top: 10px;">
				<label>
					<input id="check_box" name="form-field-checkbox" type="checkbox" class="ace" />
					<span class="lbl"> 为其他表进行相同配置</span>
				</label>
		</div>
	</div>
</div>
<div class="modal-footer">
	<button type="button" class="btn btn-sm btn-success" id="testSqlBtn"
		onclick="tableSqlTest(false);">
		<i class="icon-ok bigger-110"></i>验证发布信息
	</button>

	<button id="where-save" tableId="${tableId}" type="button"
		class="btn btn-sm btn-info"
		onclick="save(this);">
		<i class="icon-ok bigger-110"></i>&nbsp;&nbsp;&nbsp;&nbsp;保存&nbsp;&nbsp;
	</button>

	<button type="button" class="btn btn-sm btn-danger"
		data-dismiss="modal">
		<i class="icon-remove bigger-110"></i>&nbsp;&nbsp;&nbsp;&nbsp;关闭&nbsp;&nbsp;
	</button>
</div>